﻿using System.Linq;
using MvcContrib.Sorting;
using WeBlog.Interfaces;
using WeBlog.Models;
using WeBlog.Repositories;

namespace WeBlog.Models
{
    public class PostListViewModel : GridModel<Post>
    {
        private readonly PostRepository _postRepository;

        public PostListViewModel(GridSettings settings, IUnitOfWork unitOfWork ) :
            base(settings)
        {
            settings.DefaultSortColumn = "PublishDate";
            settings.Direction = SortDirection.Descending;
            _postRepository = new PostRepository(unitOfWork);
        }

        public override IQueryable<Post> GetSuperSet()
        {
            return _postRepository.PublishedPosts();
        }
    }
}